<?php

namespace Biz\model\course;

use Doraemon\pockets\datebase\BaseDbModel;

class CourseIapReceiptData extends BaseDbModel
{

    const _CONFIG_FILE_ = 'db_course';

    const _CONFIG_SELECT_ = 'db_course';

    const _DATABASE_ = 'hhz_course';

    const _TABLE_NAME = 'course_iap_receipt_data';

    public static function addInfo($receiptId, $receipt)
    {
        $info = self::getByWhere(['id' => $receiptId], 'id');
        if (!$info) {
            $data = ['id' => $receiptId, 'receipt_data' => $receipt];
            return self::insertData($data);
        }
    }

    public static function selectByWhere($where, $select = '*')
    {
        $list = self::select($select, $where);
        return $list;
    }

    public static function getByWhere($where, $select = '*')
    {
        return self::get('*', $where);
    }

    public static function selectCount($where)
    {
        return self::count($where);
    }

    public static function insertData($data)
    {
        $ret = self::insert($data);
        if ($ret->errorCode() !== '00000') {
            return false;
        }
        return true;
    }

    public static function updateData($data, $where)
    {
        $ret = self::update($data, $where);
        if ($ret->errorCode() !== '00000') {
            return false;
        }
        return true;
    }

}

